/*
 * @Date: 2022-04-26 10:38:04
 * @LastEditors: wuyuxin
 * @LastEditTime: 2022-04-29 11:31:12
 * @FilePath: \Vue3-ts-cms\src\utils\date-format.ts
 * @description: 文件描述
 */
import dayjs from 'dayjs'
import utc from 'dayjs/plugin/utc'

dayjs.extend(utc)

const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss'

export function formatUtcString(
  utcString: string,
  format: string = DATE_TIME_FORMAT
) {
  return dayjs.utc(utcString).utcOffset(8).format(format)
}

export function formatTimestamp(
  timestamp: number,
  format: string = DATE_TIME_FORMAT
) {
  return dayjs(timestamp).format(format)
}
